home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.08 Aug 93 / Icons In Lists / LDEF Example 2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-06  |  1.1 KB  |  64 lines  |  [TEXT/KAHL]

  1. #include "SetUpA4.h"
  2. Pattern grey={ 170,85,170,85,170,85,170,85 };
  3.  
  4. pascal void main(message,select,r,theCell,offset,len,LH)
  5. int message,offset,len;
  6. ListHandle LH;
  7. Cell theCell;
  8. Boolean select;
  9. Rect *r;
  10. {
  11.     int l;
  12.  
  13.     RememberA0();
  14.     SetUpA4();
  15.     switch(message){
  16.         case 0: break;
  17.         case 1: 
  18.         case 2: doDraw(select,r,offset,LH); break;
  19.         case 3: break;
  20.     }
  21.     RestoreA4();
  22. }
  23.  
  24. doDraw(select,r,offset,LH)
  25. Boolean select;
  26. Rect *r;
  27. int offset;
  28. ListHandle LH;
  29. {
  30.     BitMap icon; 
  31.     Rect dst; 
  32.     char *q,*s,icnoff; 
  33.     int len;
  34.     FontInfo inf;
  35.     
  36.     EraseRect(r); 
  37.     dst=*r; 
  38.     dst.right=dst.left+16;
  39.     SetRect(&icon.bounds,0,0,16,16); 
  40.     icon.rowBytes=2;
  41.     HLock((**LH).cells);
  42.     s=q=(char *)*(**LH).cells;
  43.     q+=offset; 
  44.     s+=offset;
  45.     q+=(*q+1); 
  46.     icnoff=*q<<5;
  47.     HLock((**LH).userHandle);
  48.     icon.baseAddr=(*(**LH).userHandle)+icnoff;
  49.     CopyBits(&icon,&((**LH).port->portBits),&(icon.bounds),
  50.         &dst,0,0L);
  51.     HUnlock((**LH).userHandle);
  52.     
  53.     GetFontInfo(&inf); 
  54.     len=inf.ascent+inf.descent+inf.leading;
  55.     MoveTo(dst.right+2,(r->bottom+r->top+len)/2-inf.descent);
  56.     DrawString(s);
  57.     HUnlock((**LH).cells);
  58.     if(select){
  59.         HiliteMode&=127;
  60.         InvertRect(r);
  61.     }
  62. }
  63.  
  64.